﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CH.Easy.OpenLogin
{
    public abstract class AbstractOauthV2
    {
        /// <summary>
        /// 授权第一步 获取Authorization Code 的接口地址
        /// </summary>
        public string AuthorizeUrl { get; set; }
        /// <summary>
        /// 授权第二步 通过Authorization Code获取Access Token 的接口地址
        /// </summary>
        public string TokenUrl { get; set; }
        /// <summary>
        /// 授权第三步 通过Access Token获取OpenID 的接口地址
        /// </summary>
        public string MeUrl { get; set; }
        /// <summary>
        /// 回调地址
        /// </summary>
        public string CallBack { get; set; }

        public string AccessToken { get; set; }
        public string AppKey { get; set; }
        public string AppSecret { get; set; }
        public string OpenID { get; set; }
        public OpenType OpenType { get; set; }
        public OpenRequest OpenRequest { get; set; }
        /// <summary>
        /// 授权第一步
        /// </summary>
        /// <returns></returns>
        public abstract string GetAuthorizeUrl();
        /// <summary>
        /// 授权第二步
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public abstract AccessTokenDTO GetAccessToken(string code);
        /// <summary>
        /// 授权第三步
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public virtual CallBackDTO GetOpenID(string accessToken) 
        {
            //tx微博 不需要重写这个方法 因为再授权成功以后就已经返回这个参数了
            return new CallBackDTO() { openid = this.OpenID };
        }
    }
}
